#include "stdafx.h"
#include "ylCriticalSection.h"

using namespace yoctolog;

CriticalSection::CriticalSection()
{
	m_pCriticalSection = new CRITICAL_SECTION();
	InitializeCriticalSection (reinterpret_cast<CRITICAL_SECTION*>(m_pCriticalSection));
}


CriticalSection::~CriticalSection()
{
	// Clean up our critical section object
	DeleteCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(m_pCriticalSection));
	delete m_pCriticalSection;
}


void CriticalSection::Enter()
{
	EnterCriticalSection ( reinterpret_cast<CRITICAL_SECTION*>(m_pCriticalSection) );
}


void CriticalSection::Leave()
{
	LeaveCriticalSection ( reinterpret_cast<CRITICAL_SECTION*>(m_pCriticalSection) );
}